import { request } from ".";
import type { RESPONSE } from "../types/base";
import type { loginData, registerData, userData } from "./type/userType";

export const reqRegister = (data:registerData)=> request.post<any,RESPONSE<string>>("api/user/register",data)

export const reqLogin = (data:loginData)=>request.post<any,RESPONSE<userData> & {token:string}>("api/user/login",data);
export const reqWoami = ()=>request.get<any,RESPONSE<userData>>("api/user/womai");
export const reqCheckPass = (username:string,oldpass:string)=>request.post<any,RESPONSE<string>>("api/user/checkOldPass",{username,oldpass});
export const reqUpdatePass = (username:string,confirmPass:string)=>request.post<any,RESPONSE<string>>("api/user/updatePass",{username,confirmPass});

export const reqUpdateUser = (username:string,obj:object)=> request.put<null,RESPONSE<userData>>(`/api/user/${username}`,obj)
export const reqDelFile = (filename:string) => request.delete<null,RESPONSE>("/api/upload/",{data:{name:filename}})